/**
 * @author helio
 */
if (!SALE.window) SALE.window = {}

if (!SALE.window.ManufacturerEditWindow) {
	SALE.window.ManufacturerEditWindow = Ext.extend(SALE.basicWindow, {
		
		title: '厂商资料添加/编辑',
		closable: true,	
		collapsible  : true,
		width: 500,
		height: 330,
		plain: true,
		layout: 'fit',
		closeAction :'hide',
		layout: 'fit',
		initComponent: function(){
			this.inputForm = new Ext.FormPanel({
				frame: true,
				labelWidth: 55,
				defaultType: 'textfield',
						
				items: [{
					xtype:'fieldset',
					title: '基本信息',
					autoHeight:true,
				    anchor:'100%',
					layout:'form',
							
					items: [{
				    	xtype:'textfield',
				        fieldLabel: '厂商编号',
				        name: 'code',
				        anchor:'50%'
				    }, {
						xtype:'textfield',
						fieldLabel: '厂商名称',
		                name: 'name',
		                anchor:'95%'		
					}, {
				        xtype:'textfield',
				        fieldLabel: '厂商简称',
				        name: 'abbr',
				        anchor:'50%'
				    }, {
				        xtype:'textfield',
				        fieldLabel: '电话',
				        name: 'tel',
				        anchor:'50%'
				    }, {
				        xtype:'textfield',
				        vtype:'email',
				        fieldLabel: 'Email',
				        name: 'email',
				        anchor:'50%'			               
				    }, {
				        xtype:'textfield',
				        fieldLabel: '联系人',
				        name: 'linkman',
				        anchor:'50%'
				               
				    }, {
						xtype:'textfield',
						fieldLabel: '厂商地址',
		                name: 'address',
		                anchor:'95%'
					}]
				}],
				
				buttons: [{
		            text: '保存',
					listeners: {
						"click": function(){
							this.syncJson();
							
							if(this.formJson.code && this.formJson.code != "") {
								this.saveManufacturerInfo();
							}
							
						}.createDelegate(this)
					}
		        },{
		            text: '取消',
					listeners:{
						"click":this.cancelHandler.createDelegate(this)
					}
		        }]
			});
			
			this.items = this.inputForm;
			
			SALE.window.ManufacturerEditWindow.superclass.initComponent.call(this);
		},
		
		saveManufacturerInfo : function() {
			SALE.Action.saveManufacturerInfo(this.saveSuccessHandler.createDelegate(this), this.formJson, this.task);
		},
		
		cancelHandler : function() {
			this.clear();
			this.hide();
		}
	});
}

SALE.window.showManufacturerEditWindow = function(successCallback, initJson, task) {
	if(!this.mfurEditWin) {
		this.mfurEditWin = new SALE.window.ManufacturerEditWindow();
	}
	this.mfurEditWin.showWindow(successCallback, initJson, task);
}